﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace JiveMessenger.Models
{

    [DataContract]
    public class JiveDefaultEmoticonModel : INotifyPropertyChanged, IEmoticon, IEquatable<IEmoticon>
    {
        public EmoticonType Type
        {
            get
            {
                return EmoticonType.DefaultEmoticon;
            }
        }

        private string[] _emoticonShortcut;
                [DataMember]
        public string[] EmoticonShortcut
        {
            get { return _emoticonShortcut; }
            set
            {
                if (_emoticonShortcut != value)
                {
                    _emoticonShortcut = value;
                    RaisePropertyChanged("EmoticonShortcut");
                }
            }
        }

        private string _emoticonPath;
                [DataMember]
        public string EmoticonPath
        {
            get { return _emoticonPath; }
            set
            {
                if (_emoticonPath != value)
                {
                    _emoticonPath = value;
                    RaisePropertyChanged("EmoticonPath");
                }
            }
        }

        public JiveDefaultEmoticonModel()
        {

        }
        protected virtual void RaisePropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
        }
        public event PropertyChangedEventHandler PropertyChanged;

        public override int GetHashCode()
        {
            return (this.EmoticonPath + string.Join(",",this.EmoticonShortcut)).GetHashCode();
        }

        public override bool Equals(object obj)
        {
            return Equals(obj as IEmoticon);
        }
        public bool Equals(IEmoticon other)
        {
            if (other == null || !(other is JiveDefaultEmoticonModel))
                return false;
            return this.EmoticonPath == other.EmoticonPath && Array.Equals(this.EmoticonShortcut,((JiveDefaultEmoticonModel)other).EmoticonShortcut);
        }
    }

}
